b6dd8a
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2016 the original author or authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -114,21 +114,35 @@
public class LinkedCaseInsensitiveMap<V> extends LinkedHashMap<String, V> {
 	@Override
 	public V get(Object key) {
 		if (key instanceof String) {
-			return super.get(this.caseInsensitiveKeys.get(convertKey((String) key)));
+			String caseInsensitiveKey = this.caseInsensitiveKeys.get(convertKey((String) key));
+			if (caseInsensitiveKey != null) {
+				return super.get(caseInsensitiveKey);
+			}
 		}
-		else {
-			return null;
+		return null;
+	}
+
+	// Overridden to avoid LinkedHashMap's own hash computation in its getOrDefault impl
+	@Override
+	public V getOrDefault(Object key, V defaultValue) {
+		if (key instanceof String) {
+			String caseInsensitiveKey = this.caseInsensitiveKeys.get(convertKey((String) key));
+			if (caseInsensitiveKey != null) {
+				return super.get(caseInsensitiveKey);
+			}
 		}
+		return defaultValue;
 	}
 
 	@Override
 	public V remove(Object key) {
-		if (key instanceof String ) {
-			return super.remove(this.caseInsensitiveKeys.remove(convertKey((String) key)));
-		}
-		else {
-			return null;
+		if (key instanceof String) {
+			String caseInsensitiveKey = this.caseInsensitiveKeys.remove(convertKey((String) key));
+			if (caseInsensitiveKey != null) {
+				return super.remove(caseInsensitiveKey);
+			}
 		}
+		return null;
 	}
 
 	@Override
